<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="en">
<head>
<title>已付款记录</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="icon" href="favicon.ico" type="image/x-icon" />
<!-- END META SECTION -->

<!-- CSS INCLUDE -->        
      
<link rel="stylesheet" href="${ctx}/rs/js/zTree/css/zTreeStyle/metro.css"/>
<link rel="stylesheet" href="${ctx}/rs/css/bootstrap-table.css" />
<link rel="stylesheet" href="${ctx}/rs/css/main.css" />
<link id="theme" rel="stylesheet" href="${ctx}/rs/joli/css/theme-default.css" />

</head>
<body >


	<input type="hidden" id="type" name="type" value="${type}">
	<input type="hidden" id="contractId" name="contractId" value="${contractId}">
	<input type="hidden" id="id" name="id" value="">

		<div class="form-group" style="overflow: hidden;">
			<label for="name" class="col-sm-2 control-label item ">到账金额：</label>
			<div class="col-sm-6  ">
				<input type="text" class="form-control " id="upMoney" name="upMoney" />
			</div>
			<span class="help-block col-sm-2" id="valierr" style="color:#FF9966">*</span>
		</div>
		<div class="form-group" style="overflow: hidden;">
			<label for="name" class="col-sm-2 control-label item ">记账员：</label>
			<div class="col-sm-6  ">
				<input type="text" class="form-control " id="readMan" name="readMan" />
			</div>
			<span class="help-block col-sm-2" id="valierr" style="color:#FF9966">*</span>
		</div>
		<button class="btn btn-primary btn-sm srt-btn active" style="display: block;margin: 0 auto 5px;"
			onclick="readSave()">确认</button>
	<div class="row">
		<div class="col-xs-12">
			<table id="table1" cellpadding="0" cellspacing="0"
				data-toggle="table"
				data-url="${ctx}/contract/readList.htm" data-cache="false"
				data-striped="true"
				data-pagination="true" 
                            data-side-pagination="server"
                            data-page-list="[10, 20, 50, 100]"
                            data-page-size="20"  
				data-query-params="queryParams1">
				<thead>
					<tr class="tab-th">
						<th data-field="createTime" class="col-md-2">记账日期</th>
						<th data-field="upMoney" class="col-md-4">到账金额</th>
						<th data-field="readMan">记账员</th>
						<th data-field="remarks">备注</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
    <style>
        .tdcolor {
            background: #CCCCCC !important;
        }
    </style>
	<!-- 引入所有joli的脚本 -->
    <!-- 引入页面需要的脚本 -->
    <script src="${ctx}/rs/js/jquery.formatDate.js"></script>
    <script src="${ctx}/rs/js/jquery.form.js" type="text/javascript"></script>
    <script src="${ctx}/rs/js/my97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/rs/js/session-out-error.js"></script>
    <script type="text/javascript">
					var $table1 = $('#table1');
					$table1.on('click-row.bs.table', function(e, row, $element) {
						$table1.bootstrapTable('uncheckAll');
						$table1.bootstrapTable('check', $element.index());
						console.log(e, row, $element)
						$("#upMoney").val(row.upMoney);
						$("#readMan").val(row.readMan);
						$("#id").val(row.id);
						$($element[0]).siblings('tr').children('td').removeClass('tdcolor');
						$($element[0]).children('td').addClass('tdcolor');
					});

					$table1.bootstrapTable({
						height : getHeight()
					});

					//获取分辨率高度
					function getHeight() {
						return window.screen.height - 308;
					}

					$(window).resize(function() {
						$table1.bootstrapTable('resetView', {
							height : getHeight()
						});
					});
					//初始化刷新
					function refresh1() {
						var type = $("#type").val();
						var contractId = $("#contractId").val();
						$table1.bootstrapTable('refresh', {
							silent : true,
							cache : false,
							url : '${ctx}/contract/adduppage.htm',
							query : {
								contractId : contractId,
								type : type
							}
						});
						$table1.bootstrapTable();
					}

					function queryParams1(params) {
						var type = $("#type").val();
						var id = $("#id").val();
						var contractId = $("#contractId").val();
						return {
							id : id,
							contractId : contractId,
							type : type
						};
					}
					function readSave() {
						var type = $("#type").val();
						var id = $("#id").val();
						var upMoney = $("#upMoney").val();
						var readMan = $("#readMan").val();
						var contractId = $("#contractId").val();
						var exp = /^(\-?(0|[1-9]\d{0,})((\.[0-9]{1,2})?))$/;//可以为负的金额
						if (upMoney == "" || readMan == "") {
							 bootstrapQ.msg({
                                 msg : '请输入必填项',
                                 type : 'danger',
                                 time : 2000
                             });
							return;
						}
						if (!exp.test(upMoney)) {
							bootstrapQ.msg({
                                msg : '请输入正确的金额',
                                type : 'danger',
                                time : 2000
                            });
							return;
						}
						$.ajax({
							url : "${ctx}/contract/readSave.htm",
							type : "post",
							data : {
								id : id,
								type : type,
								readMan : readMan,
								contractId : contractId,
								upMoney : upMoney
							},
							success : function(text) {

								if (!$('.unable').is(':hidden')) {
									$(".unable").hide();
								}
								// 普通消息提示条
								bootstrapQ.msg({
									msg : '记账成功！',
									type : 'success',
									time : 2000
								});
// 								alert("记账成功");
								//触发隐藏确认的按钮，引用回调方法关闭窗口并刷新列表
								$("button.bsok").click();
// 								setTimeout(
// 										"window.location.reload(true)",
// 										2000);
								}
							});
					}
				

					/*   function responseHandler(res){
					      // TODO 数据加到页面
					         var html="";
					             html += '  <div  id ="success" >'+
					                        ' <label for="recipient-name" id = "app">'+"截止当前平台已创建app  "+res.app+" 个"+'</label><br>'+
					                        ' <label for="recipient-name" id = "wet">'+"截止当前平台已创建微信公众号  "+res.wet+" 个"+'</label><br>'  +
					                        ' <label for="recipient-name" id = "fm">'+"截止当前平台已创建频率  " +res.fm+" 个"+'</label><br>'+
					                        ' <label for="recipient-name"id = "adver">'+"截止当前平台已发布综合广告       "+res.adver+" 个"+'</label><br>'+
					                        ' <input type="hidden" id = "plant_id" value='+res.plant_id+'> '+
					                        ' </div>'+
					                        '<div class="row">'+
					                        ' <input type="hidden" id = "plant_id" value="${plant_id}">'+
					                        '<label for="recipient-name" class="control-label col-sm-4">'+"平台媒体资源数据设置"+'</label>'+
					                        ' <input type="text" class="col-sm-4" style="height: 30px;" id="media_counts" name ="media_counts" value='+res.media_counts+'>'+
					                        '<label for="recipient-name" class="control-label col-sm-4">'+"此数据将公布在云道平台登录首页"+'</label>'+
					                        '</div>'+
					                        '<div class="text-center">'+
					                        ' <button class="btn btn-primary btn-sm srt-btn active" onclick="mediaSave()">'+"确认公布"+'</button>'+
					                        '</div>';
					                   
					            $("#success").html(html);
					      return res;
					  } */

				
				</script>
    
  </body >
</html>
